<template>
  <div class="header">
    <div class="topbar" >
      <div class="left">欢迎来到小米商城</div>
      <div class="right">
        <ul>
          <li class="denglu_li"><span class="denglu" @click="login">登录</span></li>
          <li>|<span class="zhuce">注册</span></li>
          <li>我的订单</li>
          <li>我的收藏</li>
          <li> <i class="el-icon-shopping-cart-full"></i> 购物车</li>
        </ul>
      </div>
    </div>
    <div class="banxin" >
   <div class="logo">
    <router-link to="/">
    <img src="../assets/imgs/logo.png" alt class="image" />
    </router-link>
    <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" >
    <el-menu-item index="/"> <router-link to="/">首页</router-link></el-menu-item>
    <el-menu-item index="/goods" ><router-link to="/goods">全部商品</router-link></el-menu-item>
    <el-menu-item index="/orders"> <router-link to="/seckill">秒杀</router-link></el-menu-item>
    <el-menu-item index="/about"><router-link to="/about">关于我们</router-link> </el-menu-item>
    </el-menu>
    <div class="search"> <el-input placeholder="请输入内容" prefix-icon="el-icon-search" v-model="search"></el-input></div>
   </div>
    </div>
  </div>
</template>

<script>
import { mapActions } from "vuex";
export default {
  name: 'HeaderVue',
  data() {
      return {
        activeIndex: "", // 头部导航栏选中的标签
        search: "", // 搜索条件
      };
    },
    methods: {
      ...mapActions(["setUser", "setShowLogin"]),
     login(){
       // 点击登录按钮, 通过更改vuex的showLogin值显示登录组件
       this.setShowLogin(true);
     }
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" scoped >
 @import "../total.less";
 .header{
  padding: 0;
  display: inline;
  // background: pink;
  .topbar{
  height: 40px;
  background-color: #3d3d3d;
  margin-bottom: 20px;
  width: 100%;
  padding:0;
  color: #b0b0b0;
  display: flex;
  justify-content: space-between;
  .left{
    display: flex;
    align-items: center;
    margin-left: 200px;
  }
  .right{
    display: flex;
    margin-right: 200px;
    ul{
      display: flex;
      margin-right: 20px;
      align-items: center;
      .denglu_li{
        margin-right: 5px;
      }
      li{
        &:hover{
          color: #fff;
        }
        margin-right: 20px;
        cursor: pointer;
        margin-right: 20px;
        list-style-type:none;
        .zhuce{
          padding-left: 5px;
        }
      }
    }
  }
 }
 .logo{
  display: flex;
   border-bottom: 1px solid #e6e6e6;
  .image{
   margin-right: 100px;
  }
  .search{
    margin-left: auto;
    text-align: center;
    line-height: px;
  }
 }
 }
</style>
